home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / c_wndw.zip / BRACKET.C < prev    next >
Text File  |  1989-05-25  |  1KB  |  44 lines

  1. /*    (c) Marietta Systems, Inc.  1987
  2.     All rights reserved  */
  3. #include "mtest.h"
  4. /*
  5. *
  6. *      This program reads through a text file to create a map of '{' and '}'
  7. *
  8. */
  9. void main(){
  10. long rec_nbr = 0L;
  11. int line, fh = 0, tab = 0, x = 1, z;
  12. byte *text, fname[66], *ptr, out[81];
  13. clr_scrn("Examine a program for {}");
  14. strcpy(fname, "marietta\\hashtest.c");
  15. while (fh <= 0){
  16.     display("Enter the file name  ", 19, 1, low);
  17.     accept(fname, left, alt_reverse, 50, 0);
  18.     fh = fileopen(fname, ascii, readonly);
  19.     if (!fh) disp_err("File not found", 1);
  20.     }
  21. mk_wndw(TOP_LINE, 0, SCRN_LEN, SCRN_WID + 1, "");
  22. while (fileread(fh, nextrec, &rec_nbr) > 0){
  23.     text = FN[fh].record;
  24.     line = (int) rec_nbr - 1;
  25.     if ((ptr = strpbrk(text, "}{")) == NULL) continue;
  26.     for (z = 0 ; ptr[z] != 0 ; z++){
  27.         if (ptr[z] == '{') tab++;
  28.         if (ptr[z] == '}') tab--;
  29.         }
  30.     text[strlen(text) - 1] = 0; /* cull out the \n character */
  31.     sprintf(out, "%4u:%u %.72s", line, tab, text);
  32.     if (x == WINDOW[W_NUM].H){ /* halt and scroll at bottom of screen */ 
  33.         disp_msg("Press any key to continue", 1); 
  34.         read_kb();
  35.         x -= 10; scroll(10, 0);
  36.         disp_msg("", 0);
  37.         }
  38.     display(out, x++, 1, high);
  39.     } /* end while */
  40. disp_msg("Press any key to finish", 1);
  41. read_kb();
  42. goodbye(0);
  43. }
  44.